//
//  BottomOptionView.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/11/15.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "BottomOptionView.h"

@implementation BottomOptionView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        
        UIButton *Allbtn=[UIButton buttonWithType:UIButtonTypeCustom];
        
        Allbtn.frame=CGRectMake(0, 0, SCREEN_WIDTH/2.0, 50);
        
        Allbtn.backgroundColor=kColorRGB(0xface48);
        
        [Allbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        [Allbtn setTitle:@"全选" forState:UIControlStateNormal];
        
        [Allbtn setTitle:@"取消" forState:UIControlStateSelected];
        
        [Allbtn addTarget:self action:@selector(selectAll:) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:Allbtn];
        
        UIButton *Surebtn=[UIButton buttonWithType:UIButtonTypeCustom];
        
        Surebtn.frame=CGRectMake(SCREEN_WIDTH/2.0,0, SCREEN_WIDTH/2.0, 50);
        
        Surebtn.backgroundColor=TBColorProvideBtnbg;
        
        [Surebtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        [Surebtn setTitle:@"确定" forState:UIControlStateNormal];
   
        [Surebtn addTarget:self action:@selector(sureToChoose:) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:Surebtn];
        
        
    }
    
    return self;
}

-(void)selectAll:(UIButton*)sender
{
    sender.selected=!sender.selected;
    
    if (sender.selected) {
        
        _block(1);
        
    }else{
        
         _block(2);
        
    }
    
    
}


-(void)sureToChoose:(UIButton*)sender
{
    
     _block(3);
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
